#账户表，用以存储登录系统的用户名和密码
class CreateAccounts < ActiveRecord::Migration
  def self.up
    create_table :accounts do |t|
      t.string        :username                                                 #登录名
      t.string        :password                                                 #密码
      t.string        :user_type                                                #用户类型 1为管理员 0为普通用户

      t.integer   :is_locked     ,:limit => 1 ,:default => 0                    #锁定 1为True 0为False
      t.integer   :lock_version  ,:default => 0                                 #乐观锁
      t.timestamps                                                              #创建时间和更新时间
    end
    Account.create(:username => "admin" ,:password => "123" ,:user_type => "admin")
    Account.create(:username => "user" ,:password => "123" ,:user_type => "user")
  end

  def self.down
    drop_table :accounts
  end
end
